
<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>系统设置</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css">

    <style>
        .main-container .layui-form-item{
            margin-top: 5px!important;
            margin-bottom: 5px!important;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox" style="background-color: whitesmoke">
        <div class="main-container">

            <div class="layui-card">
                <div class="layui-card-header">小程序设置</div>
                <div class="layui-card-body">
                    <div class="layui-tab-item layui-show" style="padding-top: 30px;padding-bottom: 50px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">AppID 小程序ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="mailHost" value="" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <br/>
                        <div class="layui-form-item">
                            <label class="layui-form-label">AppSecret 小程序密钥</label>
                            <div class="layui-input-block">
                                <input type="text" name="mailPort" value="" placeholder="" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">微信支付设置</div>
                <div class="layui-card-body">
                    <div class="layui-tab-item layui-show" style="padding-top: 30px;padding-bottom: 50px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信支付商户号 MCHID</label>
                            <div class="layui-input-block">
                                <input type="text" name="mailHost" value="" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <br/>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信支付密钥 APIKEY</label>
                            <div class="layui-input-block">
                                <input type="text" name="mailPort" value="" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <br/>
                        <div class="layui-form-item">
                            <label class="layui-form-label">apiclient_cert.pem</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                  <button type="button" class="layui-btn layui-btn-normal" id="apicert">选择文件</button>
                                  <button type="button" class="layui-btn" id="cert">开始上传</button>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="layui-form-item">
                            <label class="layui-form-label">apiclient_key.pem</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                  <button type="button" class="layui-btn layui-btn-normal" id="apikey">选择文件</button>
                                  <button type="button" class="layui-btn" id="key">开始上传</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="setup-save">
                保存
            </button>
            <button type="reset" class="pear-btn pear-btn-default pear-btn-sm">
                重置
            </button>
        </div>
    </div>
</form>
</body>

    <script src="/component/layui/layui.js"></script>
    <script src="/component/pear/pear.js"></script>
    <script src="/admin/js/jquery.min.js"></script>

<script>
layui.use(['element','form','popup','jquery','upload'],function(){
    let form = layui.form;
    let popup = layui.popup;
    let $ = layui.jquery;
    let upload = layui.upload;
    upload.render({
        elem: '#apicert'
        ,url: 'https://httpbin.org/post' //改成您自己的上传接口
        ,auto: false
        //,multiple: true
        ,bindAction: '#cert'
        ,done: function(res){
            layer.msg('上传成功');
            console.log(res)
        }
    });
    upload.render({
        elem: '#apikey'
        ,url: 'https://httpbin.org/post' //改成您自己的上传接口
        ,auto: false
        //,multiple: true
        ,bindAction: '#key'
        ,done: function(res){
            layer.msg('上传成功');
            console.log(res)
        }
    });
    form.on('submit(setup-save)', function (data) {
        $.ajax({
            url: '/system/setup/save',
            data: JSON.stringify(data.field),
            dataType: 'json',
            contentType: 'application/json',
            type: 'put',
            success: function (result) {
                if (result.success) {
                    popup.success(result.msg, function () {
                        window.location.reload();
                    });
                } else {
                    popup.failure(result.msg);
                }
            }
        });
        return false;
    });
})
</script>
</html>